import { ElMessage, messageConfig } from "element-plus";

let defaults = {
  offset: 90,
  showClose: true,
};

const getParams = options => {
  let ret;
  if (typeof options == "string") {
    ret = {
      ...defaults,
      message: options,
    };
  } else if (typeof options == "object") {
    ret = {
      ...defaults,
      ...options,
    };
  }
  return ret;
};

export const toast = {
  error: options => {
    ElMessage.error(getParams(options));
  },
  success: options => {
    ElMessage.success(getParams(options));
  },
  warning: options => {
    ElMessage.warning(getParams(options));
  },
  info: options => {
    ElMessage.info(getParams(options));
  },
};
//pdf.js中需要用到提示
window.toast = toast;
